
SHELL = /bin/bash
CC=g++
CFLAGS=-g -c -Wall
LDFLAGS=

BASE_DIR=..
OBJECTS_DIR=$(BASE_DIR)/build
BIN_DIR=$(BASE_DIR)/bin
LIB_DIR=-L$(BASE_DIR)/lib

SOURCES := main.cpp \
	gui.cpp \
	application.cpp

OBJECTS := $(SOURCES:%.cpp=$(OBJECTS_DIR)/%.o)

FRAMEWORKS=-framework GLUT -framework OpenGL -framework Cocoa
INCLUDES=-I../include/glui -I../include
LIBRARIES=-lglui

EXECUTABLE=x-shader

all: $(OBJECTS_DIR) $(BIN_DIR) $(LIB_GLUI) $(SOURCES) $(EXECUTABLE)

$(EXECUTABLE): $(OBJECTS)
	$(CC) $(LDFLAGS) $(LIB_DIR) $(LIBRARIES) $(FRAMEWORKS) $(OBJECTS) -o $(BIN_DIR)/$@

$(OBJECTS_DIR)/%.o: %.cpp
	$(CC) $(CFLAGS) $(INCLUDES) $< -o $@

clean:
	@echo "Clean up ..."
	rm -f $(OBJECTS_DIR)/*.o
	rm -f $(BIN_DIR)/$(EXECUTABLE)

$(OBJECTS_DIR):
	@echo "Creating objects directory ..."
	mkdir -p $@ 2>/dev/null

$(BIN_DIR):
	@echo "Creating output directory ..."
	mkdir -p $@ 2>/dev/null

$(LIB_GLUI):
	cd glui/src
	make
	cd -
	cp -f lib/libglui.a ../lib

run:
	./$(BIN_DIR)/$(EXECUTABLE)&

